package written_examination;
import java.util.*;

public class Parenthesis_1128_2 {
    public static boolean chkParenthesis(String A, int n) {
        // write code here
        Deque<Character> stack = new LinkedList<>();
        char[] ch = A.toCharArray();
        for(int i = 0;i < ch.length;i++){
            if(ch[i] != '(' && ch[i] != ')'){
                return false;
            }
        }
        for(char c : ch){
            if(c == '('){
                stack.push(c);
            }else{
                if(stack.isEmpty()){
                    return false;
                }
                char left = stack.pop();
                if(left == ')'){
                    return false;
                }
            }
        }
        if(stack.isEmpty()){
            return true;
        }else{
            return false;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String n = scanner.nextLine();
        System.out.println(chkParenthesis(n, 6));

    }
}
